<?php

/* @var $this yii\web\View */

use yii\helpers\Html;
use yii\web\JsExpression;
use daixianceng\echarts\ECharts;
use app\models\Sale;

$this->title = '销售量排名';
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    .pagenum{
        width: 50px;
        text-align: center;
    }
    .mysearch{
        width: 60px;
        text-align: center;
    }
</style>
<div class="site-pagerank_search">
    <h2>销售量排名</h2>
<div>
    <?= Html::label('时间', 'dayid', []) ?>
    <?= Html::input('text', 'dayid', '', ['id'=>'mydayid']) ?>
    <?= Html::Button('查询', ['class' => 'submit','id'=>'chaxun']) ?>
</div>

    <div>
        <div class="pagerank-list">
            <ul id="mylist">

            </ul>
        </div>

        <div class="page">
            <?= Html::button('上一页', ['id' => 'mypreage']) ?>
            <?= Html::input('text', 'page',1, ['id' =>'curpage','readonly'=>true,'class'=>'pagenum']) ?>
            <?= Html::button('下一页', ['id' => 'mynextage']) ?>
            <?= Html::input('text', 'searchinput','', ['id' =>'searchinput','class'=>'mysearch']) ?>
            <?= Html::button('搜索', ['id' => 'mysearch']) ?>
        </div>
    </div>
</div>

<?php $this->beginBlock('myjs') ?>
function getdata(dayid,page) {
$.ajax({
type: "POST",
url: '<?=\Yii::getAlias('@web')?>/sort/ajaxcnt',
dataType: "json",
data:
{
dayid:dayid,
page:page,
},
success: function(data)
{
$("#curpage").val(parseInt(data.page)+1);
$("#mylist").empty();
for(var i=0;i<data.agents.length;i++)
{
    var k=20*data.page;
    var pagent=data.agents[i]['sale_nbr'];
    var count=data.agents[i]['cnt'];
    $("#mylist").append("<li>"+parseInt(k+i+1)+"&emsp;"+pagent+"&emsp;"
    +"销售量："+count+"&emsp;"
    +"<a href='sale?airline="+pagent+"'>全市场内销售额(量)</a>"+"&emsp;"
    +"<a href='topc?airline="+pagent+"&dayid="+dayid+"'>销售量Top</a>"+"&emsp;"
    +"<a href='topr?airline="+pagent+"&dayid="+dayid+"'>销售额Top</a>"+"&emsp;"
    +"<a href='in?agent="+pagent+"'>入度</a>"+"&emsp;"
    +"<a href='out?agent="+pagent+"'>出度</a>"+"&emsp;"
    +"</li>");
}
},
error: function(jqXHR)
{
alert("发生错误：" + jqXHR.status);
},
});
}
$("#chaxun").click(function(){
getdata($("#mydayid").val(),0);
});
$("#mypreage").click(function(){
var curpage=$("#curpage").val();
getdata($("#mydayid").val(),parseInt(curpage)-1-1);
});
$("#mynextage").click(function(){
var curpage=$("#curpage").val();
getdata($("#mydayid").val(),parseInt(curpage)-1+1);
});
$("#mysearch").click(function(){
var curpage=$("#searchinput").val();
getdata($("#mydayid").val(),parseInt(curpage)-1);
});
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['myjs'], \yii\web\View::POS_READY); ?>